<template>
  <table>
    <tr>
      <td>发布时间</td>
      <td>任务标题</td>
      <td>操作</td>
    </tr>
    <tr v-for="(item, index) in task_list" :key="index">
      <td>{{ datetime(item.create_date) }}</td>
      <td>{{ item.content_title }}</td>
      <td>
        <van-button type="default" @click="desc_task(item.id)">详情</van-button>
      </td>
    </tr>
  </table>
</template>

<script>
import { datetime } from "../utils/utils";
export default {
  data() {
    return {
      datetime,
      task_list: "",
      user_id: localStorage.getItem("id"),
    };
  },
  mounted() {
    this.task_show()
  },
  methods: {
    task_show: function () {
      this.myaxios(this.host + "study/tasks/", "get", {
        user_id: this.user_id,
      }).then((data) => {
        if (data.code == 200) {
          this.$toast.success(data.msg);
          this.task_list = data.data;
        } else {
          this.$toast.fail(data.msg);
        }
      });
    },
    desc_task: function (id) {
      this.$router.push({ path: "/menu/task_info", query: { task_id: id } });
    },
  },
};
</script>

<style>
</style>